之前沒整理程式碼的習慣
經常想到某些程式碼
就要翻以前寫的
覺得有點浪費時間
之後有用到就貼上來 慢慢更新
然後我會打一些關鍵字
方便自己用Ctrl + F 搜尋
#kaggle提交 csv存檔
df.to_csv('submission.csv',index=False)
from sklearn.model_selection import GroupKFold
#5折 kfold 交叉驗證
#df.id id:要5折的項目
gkf = GroupKFold(n_splits = 5)
df['fold'] = -1
for fold, (train_idx, val_idx) in enumerate(gkf.split(df, groups = df.id.tolist())):
df.loc[val_idx, 'fold'] = fold
import pylab as plt
#show圖片 plt
img = plt.imread('path')
plt.imshow(img)
from kaggle_datasets import KaggleDatasets
#TPU上傳資料集
COMPETITION_NAME = "name"
GCS_DS_PATH = KaggleDatasets().get_gcs_path(COMPETITION_NAME)
import cv2
#resize
img = cv2.imread('path')
img = cv2.resize(img, (600, 600), interpolation=cv2.INTER_CUBIC)
cv2.imwrite('path', img)
# 重新排序index
df.reset_index(drop=True)